package p2p.simulation;

import p2p.logic.connection.client.Client;
import p2p.peer.Peer;

public class Simulator {
	
	private Simulation simulation = Simulation.getInstance();
	
	private final String ip = "127.0.0.1";
	private Peer peer;
	
	private int spawnAmount = 2;

	
	public Simulator(Peer peer){
				
		this.peer = peer;
		
	}
	
	public void simulate(){

		if (Simulation.getInstance().isRunning())
			for (int i = 0; i < spawnAmount; i++)
				spawn();
	
	}
	
	public void spawn(){
		
		Client c = new Client(ip, simulation.getOpenPort());
		
		this.peer.spawn(c);
		
	}
	
	public void leave(){
		this.peer.leave();
	}
	
	public void broadCast(){
		this.peer.broadCast();
	}
	
	
}
